package com.hontech.bvapp2.ui.parts.heat

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bvapp2.R
import com.hontech.bvapp2.device.cp.Heat
import com.hontech.bvapp2.ui.dialog.runProg
import com.hontech.bvapp2.utils.onClick

class HeatDrawHeatCtrlParts (context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_heat_draw_heat_ctrl, this)

        val drawStop = view.findViewById<Button>(R.id.id_heat_draw_ctrl_btn_draw_stop)
        val drawExec = view.findViewById<Button>(R.id.id_heat_draw_ctrl_btn_draw_exec)
        val waterStop = view.findViewById<Button>(R.id.id_heat_draw_ctrl_btn_water_stop)
        val waterExec = view.findViewById<Button>(R.id.id_heat_draw_ctrl_btn_water_exec)
        val steamStop = view.findViewById<Button>(R.id.id_heat_draw_ctrl_btn_steam_release)
        val steamExec = view.findViewById<Button>(R.id.id_heat_draw_ctrl_btn_steam_pre_heat)

        drawStop.onClick {
            runProg("抽水停止", "") {
                Heat.drawHeatCtrl(0)
            }
        }
        drawExec.onClick {
            runProg("抽水运行", "") {
                Heat.drawHeatCtrl(1)
            }
        }
        waterStop.onClick {
            runProg("热水加热停止", "") {
                Heat.drawHeatCtrl(2)
            }
        }
        waterExec.onClick {
            runProg("热水加热运行", "") {
                Heat.drawHeatCtrl(3)
            }
        }
        steamStop.onClick {
            runProg("蒸汽加热停止", "") {
                Heat.drawHeatCtrl(4)
            }
        }
        steamExec.onClick {
            runProg("蒸汽加热运行", "") {
                Heat.drawHeatCtrl(5)
            }
        }
    }
}